import { Controller, Post, Body, UseGuards } from '@nestjs/common';
import { BasedataService } from './basedata.service';
import { CfsStorageDto, ClientDto, CntrSizeDto, CntrTypeDto, CyCfsAreaDto, CyCfsDto, PlaceDto, SCodeDto } from './dto/create-basedatum.dto';
import { QueryCfsStorageDto, UpdateCfsStroageDto, UpdateClientDto, UpdateCntrSizeDto, UpdateCntrTypeDto, UpdateCyCfsAreaDto, UpdateCyCfsDto, UpdatePlaceDto, UpdateSCodeDto } from './dto/update-basedatum.dto';
import { ApiBody, ApiOkResponse, ApiOperation, ApiTags, getSchemaPath } from '@nestjs/swagger';
import { DeleteDto, DeletePrimaryObjDto, DeleteStrPrimaryDto, ResponseJson, SqlQueryDto } from '@/common/type/app.dto';
import { YhLoggerService } from '@/shared/yhlogger.service';
import { AuthGuard } from '@/common/guard/auth.guard';
@ApiTags('基础数据')
@Controller('basedata')
@UseGuards(AuthGuard)
export class BasedataController {
    constructor(private readonly basedataService: BasedataService, private readonly logger: YhLoggerService) { }

    @Post('damcodcreate')
    async createDamCod(@Body() data: SCodeDto) {
        return await this.basedataService.createDamCod(data);
    }

    @Post('damcodupdate')
    async updateDamCod(@Body() data: UpdateSCodeDto) {
        return await this.basedataService.updateDamCod(data);
    }

    @Post('damcoddelete')
    async deleteDamCod(@Body() data: DeletePrimaryObjDto) {
        return await this.basedataService.deleteDamCod(data);
    }

    @Post('damcodquery')
    async queryDamCod(@Body() data: SqlQueryDto) {
        return await this.basedataService.queryDamCod(data);
    }

    @Post('cntrsizecreate')
    @ApiOperation({ summary: '箱尺寸增加' })
    @ApiOkResponse({
        schema: {
            allOf: [
                { $ref: getSchemaPath(ResponseJson) },
                {
                    properties: {
                        obj: {
                            type: 'object',
                            description: '箱尺寸',
                            $ref: getSchemaPath(CntrSizeDto)
                        }
                    },

                }
            ]
        }
    })
    async createCntrSize(@Body() cntrsiz: CntrSizeDto) {
        return await this.basedataService.createCntrSize(cntrsiz);
    }

    @Post('cntrsizeupdate')
    @ApiOperation({ summary: '箱尺寸修改' })
    @ApiOkResponse({ type: ResponseJson })
    async updateCntrSize(@Body() cntrsiz: UpdateCntrSizeDto) {
        return await this.basedataService.updateCntrSize(cntrsiz);
    }

    @Post('cntrsizedelete')
    @ApiOperation({ summary: '箱尺寸删除' })
    @ApiOkResponse({ type: ResponseJson })
    async deleteCntrSize(@Body() ids: DeleteStrPrimaryDto) {
        return await this.basedataService.deleteCntrSizes(ids);
    }

    @Post('cntrsizequery')
    @ApiOperation({ summary: '箱尺寸查询'})
    @ApiBody({ type: SqlQueryDto })
    @ApiOkResponse({
        schema: {
            allOf: [
                {$ref: getSchemaPath(ResponseJson)},
                {
                    properties: {
                        obj: {
                            type: 'array',
                            description: '箱尺寸',
                            items: {
                                $ref: getSchemaPath(CntrSizeDto)
                            }
                        }
                    },

                }
            ]
        }
    })    
    async queryCntrSize(@Body() query: SqlQueryDto) {
        return await this.basedataService.queryCntrSizes(query);
    }

    @Post('cntrtypecreate')
    @ApiOperation({ summary: '箱类型增加' })
    @ApiOkResponse({
        schema: {
            allOf: [
                { $ref: getSchemaPath(ResponseJson) },
                {
                    properties: {
                        obj: {
                            type: 'object',
                            description: '箱类型',
                            $ref: getSchemaPath(CntrTypeDto)
                        }
                    },

                }
            ]
        }
    })
    async createCntrType(@Body() cntrTyp: CntrTypeDto) {
        return await this.basedataService.createCntrType(cntrTyp);
    }

    @Post('cntrtypeupdate')
    @ApiOperation({ summary: '箱类型修改' })
    @ApiOkResponse({ type: ResponseJson })
    async updateCntrType(@Body() cntrtyp: UpdateCntrTypeDto) {
        return await this.basedataService.updateCntrType(cntrtyp);
    }

    @Post('cntrtypedelete')
    @ApiOperation({ summary: '箱类型删除' })
    @ApiOkResponse({ type: ResponseJson })
    async deleteCntrType(@Body() ids: DeleteStrPrimaryDto) {
        return await this.basedataService.deleteCntrTypes(ids);
    }

    @Post('cntrtypequery')
    @ApiOperation({ summary: '箱类型查询'})
    @ApiBody({ type: SqlQueryDto })
    @ApiOkResponse({
        schema: {
            allOf: [
                {$ref: getSchemaPath(ResponseJson)},
                {
                    properties: {
                        obj: {
                            type: 'array',
                            description: '箱类型',
                            items: {
                                $ref: getSchemaPath(CntrTypeDto)
                            }
                        }
                    },

                }
            ]
        }
    })    
    async queryCntrType(@Body() query: SqlQueryDto) {
        return await this.basedataService.queryCntrTypes(query);
    }

    @Post('cycfscreate')
    async createCyCfs(@Body() data: CyCfsDto) {
        return await this.basedataService.createCyCfs(data);
    }

    @Post('cycfsupdate')
    async updateCyCfs(@Body() data: UpdateCyCfsDto) {
        return await this.basedataService.updateCyCfs(data);
    }

    @Post('cycfsdelete')
    async deleteCyCfs(@Body() data: DeleteDto) {
        return await this.basedataService.deleteCyCfs(data);
    }

    @Post('cycfsquery')
    async queryCyCfs(@Body() data: SqlQueryDto) {
        return await this.basedataService.queryCyCfs(data);
    }

    @Post('cfsstroageratecreate')
    async createcfsstroagerate(@Body() data: CfsStorageDto) {
        return await this.basedataService.createStroageRate(data);
    }

    @Post('cfsstroagerateupdate')
    async updatecfsstroagerate(@Body() data: UpdateCfsStroageDto) {
        return await this.basedataService.updateStroageRate(data);
    }

    @Post('cfsstroageratedelete')
    async deletecfsstroagerate(@Body() data: DeleteDto) {
        return this.basedataService.deleteStroageRate(data);
    }
    @Post('cfsstroageratequery')
    async querycfsstroagerate(@Body() data: QueryCfsStorageDto) {
        return await this.basedataService.queryStroageRate(data);
    }

    @Post('cycfsareacreate')
    async createCyCfsArea(@Body() data: CyCfsAreaDto) {
        return await this.basedataService.createCyCfsArea(data);
    }

    @Post('cycfsareaupdate')
    async updateCyCfsArea(@Body() data: UpdateCyCfsAreaDto) {
        return await this.basedataService.updateCyCfsArea(data);
    }

    @Post('cycfsareadelete')
    async deleteCyCfsArea(@Body() data: DeleteDto) {
        return await this.basedataService.deleteCyCfsArea(data);
    }

    @Post('cycfsareaquery')
    async queryCyCfsArea(@Body() data: SqlQueryDto) {
        return await this.basedataService.queryCyCfsArea(data);
    }

    @Post('clientcreate')
    async createClient(@Body() data: ClientDto) {
        return await this.basedataService.createClient(data);
    }

    @Post('clientupdate')
    async updateClient(@Body() data: UpdateClientDto) {
        return await this.basedataService.updateClient(data);
    }

    @Post('clientdelete')
    async deleteClient(@Body() data: DeleteDto) {
        return await this.basedataService.deleteClient(data);
    }

    @Post('clientquery')
    async queryClient(@Body() data: SqlQueryDto) {
        return await this.basedataService.queryClient(data);
    }
    @Post('placecreate')
    async createPlace(@Body() data: PlaceDto) {
        return await this.basedataService.createPlace(data);
    }

    @Post('placeupdate')
    async updatePlace(@Body() data: UpdatePlaceDto) {
        return await this.basedataService.updatePlace(data);
    }

    @Post('placedelete')
    async deletePlace(@Body() data: DeleteDto) {
        return await this.basedataService.deletePlace(data);
    }

    @Post('placequery')
    async queryPlace(@Body() data: SqlQueryDto) {
        return await this.basedataService.queryPlace(data);
    }    
}
